#!/bin/bash

# determine project name and version from debian changelog
read line < debian/changelog
PROJECT=${line%% *}
version_part=${line#* (}
VERSION=${version_part%%-*}
echo "Project '$PROJECT' version '$VERSION'"

# own build tree
DIR=/tmp/$PROJECT-$VERSION
rm $DIR -rf

# move subversion tree to tmp
svn export . $DIR

# build tar-ball
cd /tmp
tar -czf $PROJECT\_$VERSION.orig.tar.gz $PROJECT-$VERSION

# build debian package
cd $DIR
aclocal
autoconf
automake
dpkg-buildpackage -rfakeroot
cd /tmp
echo "Lintian"
lintian -v $PROJECT\_$VERSION-1.dsc > $PROJECT.lintian.log
tail $PROJECT.lintian.log
echo "Linda"
linda -v $PROJECT\_$VERSION-1.dsc > $PROJECT.linda.log
tail $PROJECT.linda.log
